package com.dd.config;



import cn.hutool.core.lang.Assert;
import io.minio.MinioClient;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;

import org.springframework.context.annotation.Configuration;


@Configuration
@Slf4j
public class MinioConfig {
    @Getter
    @Value("${minio.endpoint}")
    private String endpoint;

    @Value("${minio.accessKey}")
    private String accessKey;

    @Value("${minio.secretKey}")
    private String secretKey;
    @Getter
    @Value("${minio.bucketName}")
    private String bucketName;

    @Bean
    public MinioClient minioClient() {

        Assert.notBlank(endpoint, "MinIO endpoint can not be null");
        Assert.notBlank(accessKey, "MinIO accessKey can not be null");
        Assert.notBlank(secretKey, "MinIO secretKey can not be null");
        Assert.notBlank(bucketName, "MinIO bucketName can not be null");
     return MinioClient.builder().endpoint(endpoint).credentials(accessKey,secretKey).build();
    }





}
